package com.eric.controller;
import cn.dev33.satoken.util.SaResult;
import com.eric.domain.dto.EquipTypeDto;
import com.eric.service.IEquipTypeService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 设备类型 前端控制器
 * </p>
 *
 * @author 新哥
 * @since 2024-04-26
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/equip-type")
public class EquipTypeController {

    private final IEquipTypeService equipTypeService;

//    新增加equip_type
    @PostMapping("/saveOne")
    public SaResult saveOneEqType(@RequestBody EquipTypeDto equipTypeDto){
        return equipTypeService.saveOneEqTypeService(equipTypeDto);
    }
//    修改equip_type
    @PutMapping("/modifyOne")
    public SaResult modifyOne(@RequestBody EquipTypeDto equipTypeDto){
        return equipTypeService.modifyOneService(equipTypeDto);
    }

//    获取所有的equip_type
    @GetMapping("/getAll")
    public SaResult getAll(Integer current,Integer pageSize){
        return equipTypeService.getAllService(current,pageSize);
    }



    @GetMapping("getAllByPage")
    public SaResult getAllByPage(Integer current,Integer pageSize){
        return equipTypeService.getAllByPageService(current,pageSize);
    }

    @GetMapping("getAllCount")
    public SaResult getAllCount(){
        return equipTypeService.getAllCountService();
    }


//    根据名称模糊查询一级分类
    @GetMapping("/getByPType")
    public SaResult getByName(@RequestParam String parentType,Integer current,Integer pageSize){
        return equipTypeService.getByNameService(parentType,current,pageSize);
    }
//    根据名称模糊查询二级分类,这个接口可以设定为多功能接口
//    直接可以查询一级分类，二级分类，或者全部分类
    @GetMapping("/getByFullName")
    public SaResult getByFullName(@RequestParam String parentType,@RequestParam String childType,Integer current,Integer pageSize){
        return equipTypeService.getByFullName(parentType,childType,current,pageSize);
    }

    @DeleteMapping("/{id}")
    public SaResult deleteById(@PathVariable("id") Integer id){
        return equipTypeService.deleteByIdService(id);
    }


    @GetMapping("/{id}")
    public SaResult getById(@PathVariable("id") Integer id){
        return equipTypeService.getByIdService(id);
    }



}
